# Copyright 2024-2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Contains Skia rendering utilities that are shared between the Skia C++ renderer and the Android
# Canvas renderer. Both are based on Skia so operate very similarly and use very similar types, but
# they do not actually have any types directly in common, so these utilities establish some common
# types mimicking the distinct types in each. That way, logic that operates on the unified types can
# be shared between the two renderers, and each renderer can use mostly shared logic with minimal
# code to translate between their unique types and the unified types created here. No code in this
# package should depend on any Skia code.

load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@rules_cc//cc:cc_test.bzl", "cc_test")

package(
    default_visibility = ["//ink:__subpackages__"],
)

cc_library(
    name = "mesh_specification_data",
    srcs = [
        "mesh_specification_data.cc",
        "sksl_common_shader_helper_functions.h",
        "sksl_fragment_shader_helper_functions.h",
        "sksl_vertex_shader_helper_functions.h",
    ],
    hdrs = ["mesh_specification_data.h"],
    deps = [
        "//ink/brush:brush_paint",
        "//ink/geometry:mesh_format",
        "//ink/strokes/internal:stroke_vertex",
        "//ink/types:small_array",
        "@com_google_absl//absl/container:inlined_vector",
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:string_view",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "mesh_specification_data_test",
    srcs = ["mesh_specification_data_test.cc"],
    deps = [
        ":mesh_specification_data",
        "//ink/brush",
        "//ink/geometry:mesh_format",
        "//ink/geometry:type_matchers",
        "//ink/strokes:stroke",
        "//ink/strokes/input:stroke_input_batch",
        "//ink/strokes/internal:stroke_vertex",
        "//ink/types:duration",
        "@com_google_absl//absl/log:absl_check",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:status_matchers",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/strings:str_format",
        "@com_google_absl//absl/types:span",
        "@com_google_googletest//:gtest_main",
    ],
)
